﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace PhoneCard.Controllers
{

    [Authorize(Roles = "User")]
    public class UserController : Controller
    {
        DAL.TuiUsersDal userDal;
        public string userName = "";
        public UserController(DAL.TuiUsersDal userDal)
        {
            this.userDal = userDal;        
        }


        public IActionResult Index()
        {
          
            this.userName = HttpContext.User.FindFirst(ClaimTypes.Sid).Value;
            Entities.TuiUsers user = userDal.GetModelByUserName(userName);
            ViewBag.user = user;
            return View();
        }

        public IActionResult Password()
        {

            this.userName = HttpContext.User.FindFirst(ClaimTypes.Sid).Value;
            Entities.TuiUsers user = userDal.GetModelByUserName(userName);
            ViewBag.user = user;

            return View();
        }


      


        // 
        // GET: /HelloWorld/Welcome/ 

        public string Welcome(string name, int numTimes = 1)
        {
            // return "This is the Welcome action method...";

            //List<Entities.User> listUsers = userDal.GetListUser("");
            //string xx = "";
            //foreach (var item in listUsers)
            //{
            //    xx = xx + item.user_name;
            //}

            //return HtmlEncoder.Default.Encode($"Hello {name}, NumTimes is: {numTimes}"+xx);
            return "";



        }


    }
}
